﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class ajax_demo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DbBind();
        }
    }

    private void DbBind()
    {
        //string sql = "select top 14 * from t_user";
        string sql = "select top 10 bigname,myemail,mypic,count(*) as linkmans from dbo.vw_linkman where bigname<>'汽车画报' and bigname<>'管理员' group by bigname,myemail,mypic order by count(*) desc";
        string str = System.Configuration.ConfigurationSettings.AppSettings["ConnStr"];
        SqlConnection con = new SqlConnection(str);
        SqlDataAdapter da = new SqlDataAdapter(sql,con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        this.DataList1.DataSource = ds;
        this.DataList1.DataBind();
    }


   
    protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.FindControl("Image1") != null)
        {
            string imgurl = ((Image)e.Item.FindControl("Image1")).ImageUrl;
            if (imgurl == "user/pics/")
                ((Image)e.Item.FindControl("Image1")).ImageUrl = "user/pics/user.jpg";

        }
    }
}
